
package Kasir;

import KonekDB.LoginFrame;
import javax.swing.JOptionPane;
import Transaksi.MencatatPenyewaan;

import Help.*;
import java.util.Locale;
import Transaksi.*;
import Laporan.*;
import Mobil.*;
import java.awt.BorderLayout;
import java.util.Random;
import javax.swing.JPanel;

/**
 *
 * @author Astri
 */
public class FrameUtamaKasir extends javax.swing.JFrame {

    private Kasir kasir;
    /** Creates new form frametampilankasir */
    public FrameUtamaKasir() {
        initComponents();
        getContentPane().setLayout(new BorderLayout());
        this.setSize(400, 300);
        this.setLocation(312, 234);
        this.setResizable(true);
    
        getContentPane().add(muka());
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Smartcash = new javax.swing.JLabel();
        panel_utama = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        kasirMenu = new javax.swing.JMenu();
        catatPenyewaanItem = new javax.swing.JMenuItem();
        catatPengembalianItem = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        laporan = new javax.swing.JMenuItem();
        update_mobil = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenu4 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        Smartcash.setFont(new java.awt.Font("Tahoma", 2, 5));
        Smartcash.setText("Smartcash 1.0");

        javax.swing.GroupLayout panel_utamaLayout = new javax.swing.GroupLayout(panel_utama);
        panel_utama.setLayout(panel_utamaLayout);
        panel_utamaLayout.setHorizontalGroup(
            panel_utamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        panel_utamaLayout.setVerticalGroup(
            panel_utamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 253, Short.MAX_VALUE)
        );

        kasirMenu.setText("Transaksi");

        catatPenyewaanItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, java.awt.event.InputEvent.CTRL_MASK));
        catatPenyewaanItem.setText("Catat Transaksi Penyewaan");
        catatPenyewaanItem.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                catatPenyewaanItemMousePressed(evt);
            }
        });
        catatPenyewaanItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                catatPenyewaanItemActionPerformed(evt);
            }
        });
        kasirMenu.add(catatPenyewaanItem);

        catatPengembalianItem.setText("Catat Transaksi Pengembalian");
        catatPengembalianItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                catatPengembalianItemActionPerformed(evt);
            }
        });
        kasirMenu.add(catatPengembalianItem);

        jMenuBar1.add(kasirMenu);
        jMenuBar1.add(jMenu1);

        jMenu3.setText("Laporan");
        jMenu3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu3ActionPerformed(evt);
            }
        });

        laporan.setText("Membuat Laporan Periodik");
        laporan.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                laporanMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                laporanMousePressed(evt);
            }
        });
        laporan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                laporanActionPerformed(evt);
            }
        });
        jMenu3.add(laporan);

        update_mobil.setText("Update Mobil");
        update_mobil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                update_mobilActionPerformed(evt);
            }
        });
        jMenu3.add(update_mobil);

        jMenuBar1.add(jMenu3);

        jMenu5.setText("Help");
        jMenu5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenu5MousePressed(evt);
            }
        });
        jMenuBar1.add(jMenu5);

        jMenu4.setText("Logout");
        jMenu4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenu4MousePressed(evt);
            }
        });
        jMenu4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu4ActionPerformed(evt);
            }
        });
        jMenuBar1.add(jMenu4);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(366, Short.MAX_VALUE)
                .addComponent(Smartcash))
            .addComponent(panel_utama, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(panel_utama, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Smartcash, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void setKasir(Kasir kasir) {
        this.kasir = kasir;
    }
    
    private void catatPenyewaanItemMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_catatPenyewaanItemMousePressed

        
        // TODO add your handling code here:
}//GEN-LAST:event_catatPenyewaanItemMousePressed

    private void catatPenyewaanItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_catatPenyewaanItemActionPerformed
        // TODO add your handling code here:
        MencatatPenyewaan p = new MencatatPenyewaan();
//        p.setKasir(kasir);
        p.setVisible(true);
        this.setVisible(false);
      
    }//GEN-LAST:event_catatPenyewaanItemActionPerformed

    private void catatPengembalianItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_catatPengembalianItemActionPerformed
        // TODO add your handling code here:
        new MencatatPengembalian().setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_catatPengembalianItemActionPerformed

    private void jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu4ActionPerformed

        // TODO add your handling code here:
    }//GEN-LAST:event_jMenu4ActionPerformed

    private void jMenu4MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu4MousePressed
        
        new LoginFrame().setVisible(true);
        this.setVisible(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenu4MousePressed

    private void jMenu5MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenu5MousePressed

        new menu_help().setVisible(true);
        this.setVisible(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenu5MousePressed

    private void jMenu3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu3ActionPerformed

        
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenu3ActionPerformed

    private void laporanMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_laporanMouseClicked
        
        
        // TODO add your handling code here:
    }//GEN-LAST:event_laporanMouseClicked

    private void laporanMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_laporanMousePressed

       
        // TODO add your handling code here:
    }//GEN-LAST:event_laporanMousePressed

    private void update_mobilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_update_mobilActionPerformed

        new MobilForm().setVisible(true);
        this.setVisible(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_update_mobilActionPerformed

    private void laporanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_laporanActionPerformed

        new FormTableLaporan().setVisible(true);
        this.setVisible(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_laporanActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrameUtamaKasir().setVisible(true);
            }
        });
    }
    private JPanel muka() {
        Random random = new Random();
        int pil = random.nextInt(3);
        if(pil == 2){
            KataJalan kataJalan = new KataJalan();
            ThreadPanel thread = new ThreadPanel(kataJalan,(long) 100);
            return kataJalan;
        }else{
            BesarKecil besarKecil = new BesarKecil();
            ThreadPanel thread = new ThreadPanel(besarKecil,(long) 50);
            return besarKecil;
        }
        

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Smartcash;
    private javax.swing.JMenuItem catatPengembalianItem;
    private javax.swing.JMenuItem catatPenyewaanItem;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenu kasirMenu;
    private javax.swing.JMenuItem laporan;
    private javax.swing.JPanel panel_utama;
    private javax.swing.JMenuItem update_mobil;
    // End of variables declaration//GEN-END:variables
}
